package com.vue;

import java.awt.Color;
import java.awt.ComponentOrientation;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;

import javax.swing.JLabel;
import javax.swing.JPanel;

import com.modele.entity.Utilisateur;

/**Classe permettant d'affciher les informations relatives a un utilisateur**/

public class InfosU extends JPanel{
	
	private static final long serialVersionUID = 1L;
	
	private Fenetre fenetre;
	
	private JPanel infosListPanel;
	
	private JPanel icon;
	private JPanel iconPanel;
	
	private JLabel nom;
	private JLabel nomU;
	private JLabel prenom;
	private JLabel prenomU;
	private JLabel mail;
	private JLabel mailU;
	
	private Utilisateur utilisateur;
	
	public InfosU (Fenetre fenetre,Utilisateur utilisateur) {
		
		this.fenetre = fenetre;
		this.utilisateur = utilisateur;
		this.setPreferredSize(new Dimension(250, 250));
		this.setLayout(new GridLayout(2,1));
		this.initialize ();
		this.add(this.iconPanel);
		this.build ();
		this.add(this.infosListPanel);
	}
	
	public void initialize () {
		
		this.infosListPanel = new JPanel();
		this.infosListPanel.setPreferredSize(new Dimension(240, 100));
		this.infosListPanel.setLayout(new GridBagLayout());
		
		this.icon = new JPanel();
		this.icon.setPreferredSize(new Dimension(150, 150));
		this.icon.setBackground(Color.darkGray);
		this.iconPanel = new JPanel();
		this.iconPanel.setPreferredSize(new Dimension(240, 130));
		this.iconPanel.add(this.icon);
		
		this.nom = new JLabel("Nom : ");
		this.nom.setPreferredSize(new Dimension(100, 20));
		this.nom.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
		
		this.nomU = new JLabel(this.utilisateur.getNom());
		this.nomU.setPreferredSize(new Dimension(100, 20));
		this.nomU.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
		
		this.prenom = new JLabel("Prenom : ");
		this.prenom.setPreferredSize(new Dimension(100, 20));
		this.prenom.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
		
		this.prenomU = new JLabel(this.utilisateur.getPrenom());
		this.prenomU.setPreferredSize(new Dimension(100, 20));
		this.prenomU.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
		
		this.mail = new JLabel("Mail : ");
		this.mail.setPreferredSize(new Dimension(100, 20));
		this.mail.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
		
		this.mailU = new JLabel(this.utilisateur.getMail());
		this.mailU.setPreferredSize(new Dimension(100, 20));
		this.mailU.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
	}
	
	public void build () {
			
		GridBagConstraints gridInfosUt = new GridBagConstraints();
		gridInfosUt.insets = new Insets(0,0,0,0);
		
		gridInfosUt.gridy = -1;
		
		gridInfosUt.gridy++;
		gridInfosUt.gridx = 0;
		this.infosListPanel.add(this.nom, gridInfosUt);
		
		gridInfosUt.gridy = 0;
		gridInfosUt.gridx++;
		this.infosListPanel.add(this.nomU, gridInfosUt);
		
		gridInfosUt.gridy++;
		gridInfosUt.gridx = 0;
		this.infosListPanel.add(this.prenom, gridInfosUt);
		
		gridInfosUt.gridy = 1;
		gridInfosUt.gridx++;
		this.infosListPanel.add(this.prenomU, gridInfosUt);
		
		gridInfosUt.gridy++;
		gridInfosUt.gridx = 0;
		this.infosListPanel.add(this.mail, gridInfosUt);
		
		gridInfosUt.gridy = 2;
		gridInfosUt.gridx++;
		this.infosListPanel.add(this.mailU, gridInfosUt);
	}
}
